Add Flow and TypeScript types for sx prop#1704
Conversation
|
Hi @mjames-c! Thank you for your pull request and welcome to our community. Action RequiredIn order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you. ProcessIn order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks! |
|
@mjames-c is attempting to deploy a commit to the Meta Open Source Team on Vercel. A member of the Team first needs to authorize it. |
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Adds first-class TypeScript typing support for a React sx prop when using StyleX, and extends the TypeScript tests to validate expected sx behaviors (valid/invalid values and host-only transform rules).
Changes:
- Introduced
StyleXSxProptype and exported it from the StyleX public type surface. - Added React type augmentation so intrinsic JSX elements accept an
sxprop typed asStyleXSxProp. - Expanded TypeScript tests to cover
sxusage on host elements, arrays, and invalid cases.
Reviewed changes
Copilot reviewed 3 out of 4 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| packages/typescript-tests/src/test1.tsx | Adds TS-level usage and negative tests for sx on JSX elements and custom components. |
| packages/@stylexjs/stylex/src/types/StyleXTypes.js | Defines the StyleXSxProp Flow type. |
| packages/@stylexjs/stylex/src/types/StyleXTypes.d.ts | Defines StyleXSxProp in TypeScript and augments React DOM attributes with sx. |
| packages/@stylexjs/stylex/src/stylex.js | Re-exports StyleXSxProp from the StyleX entrypoint. |
| */ | ||
|
|
||
| /* eslint-disable no-unused-vars */ | ||
| /* eslint-disable no-unused-vars, react/no-unknown-property */ |
141b090 to
14f35aa
Compare
my company (Canva) does have a CLA with Meta but I'm waiting to be added to the list of contributors. |
|
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks! |
What changed / motivation ?
Added
sxReact prop typingsLinked PR/Issues
Fixes #1360
Screenshots, Tests, Anything Else
Pre-flight checklist
Contribution Guidelines